#include "alllineresetwidget.h"
#include "ui_alllineresetwidget.h"

AllLineResetWidget::AllLineResetWidget(QWidget *parent) :
    QWidget(parent),
    ui(new Ui::AllLineResetWidget)
{
    ui->setupUi(this);
    QStringList staggNames;
    staggNames << "all_up" << "all_down" << "odd_up" << "even_up";
    ui->all_name_staggered->addItems(staggNames);
}

AllLineResetWidget::~AllLineResetWidget()
{
    delete ui;
}

void AllLineResetWidget::setConfig(const LineInfo &line, int lineNumber)
{
    ui->groupBox->setTitle(tr("All Line%1 Setting:").arg(lineNumber));
    ui->all_begin_x->setText(QString::number(line.begin_x));
    ui->all_begin_y->setText(QString::number(line.begin_y));
    ui->all_end_x->setText(QString::number(line.end_x));
    ui->all_end_y->setText(QString::number(line.end_y));
    ui->all_station_num->setText(QString::number(line.station_num));
    std::string stag = myapp::getStaggeredFromInt(line.staggerd);
    ui->all_name_staggered->setCurrentText(QString::fromStdString(stag));
    ui->all_name_offset->setText(QString::fromStdString(myapp::getNameOffsetFromQPoint(line.name_offset)));
}

void AllLineResetWidget::getConfig(LineInfo &line)
{
    line.begin_x = ui->all_begin_x->text().toInt();
    line.begin_y = ui->all_begin_y->text().toInt();
    line.end_x = ui->all_end_x->text().toInt();
    line.end_y = ui->all_end_y->text().toInt();
    line.station_num = ui->all_station_num->text().toInt();
    line.staggerd = myapp::getStaggeredFromString(ui->all_name_staggered->currentText().toStdString());
    line.name_offset = myapp::getNameOffsetFromString(ui->all_name_offset->text().toStdString());
}
